// data from the OFR money market fund monitor
// file 1: is total investments
// file 2: drill down to north america -> USA -> government

tempfile tf_usts

import delimited "build/input/ofr_mmm/investments_in_governments_in_usa_pseudo.csv", varnames(3) rowrange(3) clear
gen date2 = date(date, "MDY", 2050)
format date2 %td
drop date
rename date2 date
order date
keep date treasury federalreserve
save `tf_usts'

import delimited "build/input/ofr_mmm/investments_by_us_prime_mmfs_total_pseudo.csv", varnames(3) rowrange(3) clear
gen date2 = date(date, "MDY", 2050)
format date2 %td
drop date
rename date2 date
order date
rename prime total_prime_mmfs

merge 1:1 date using `tf_usts', nogen

gen mdate = mofd(date)
tsset mdate
format mdate %tmm-CY

gen treasury_share = (treasury/total_prime_mmfs)*100
gen treasury_plus_fed_share = ((treasury+federalreserve)/total_prime_mmfs)*100

label var treasury_share "Treasuries"
label var treasury_plus_fed_share "Treasuries + ONRRP"

// set date
drop if mdate < ym(2020,12) 
drop if mdate > ym(2021,11) 

tsline treasury_share treasury_plus_fed_share, subtitle("Percent",  orientation(horizontal)  bexpand justification(left)) plotregion(margin(medium)) ytitle("") xtitle("") scale(*1.2)  legend(ring(0) position(10) rows(2))
gr export "analysis/output_figures/figure_prime_mmf.pdf", replace

